package cn.zyx.sys.service;

import cn.zyx.common.entity.Page;
import cn.zyx.sys.entity.Post;
import cn.zyx.sys.mapper.PostMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 岗位Service
 * @author zyx
 */
@Service
@Transactional(readOnly = true)
public class PostService {

	@Autowired
	private PostMapper postMapper;

	public Post get(String id) {
		return postMapper.get(id);
	}
	
	public List<Post> findList(Post post) {
		return postMapper.findAllList(post);
	}
	
	public Page<Post> findPage(Page<Post> page, Post post) {
		post.setPage(page); // 设置参数
		page.setCount(postMapper.findPageCount(post));
		page.setList(postMapper.findList(post));;
		return page;
	}
	
	@Transactional(readOnly = false)
	public void save(Post post) {
		postMapper.save(post);
	}
	
	@Transactional(readOnly = false)
	public void delete(Post post) {
		postMapper.delete(post);
	}
	
}